package com.example.test0.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.example.test0.model.User;
import org.apache.ibatis.annotations.*;
import org.springframework.context.annotation.Bean;

import java.util.List;

@Mapper
public interface UserMapper extends BaseMapper<User> {

    @Select("select * from user")
    public List<User> findAllUser();

    @Select("select * from user where `username`=#{username}")
    public User findByUsername(String username);

    @Select("select * from user where `username`=#{username} and `password`=#{password}")
    public User findByUser(User user);

    @Select("select * from user where `id`=#{id}")
    public User findById(User user);

    @Select("select * from user inner join imf on user.id=imf.id")
    public List<User> findAll();

    @Select("select * from user inner join imf on user.id=imf.id")
    public List<User> findAllTest();

    @Select("select * from user")
    @Results({
            @Result(column = "user", property = "user"),
            @Result(column = "id", property = "id", javaType = User.class,
                    one = @One(select = "com.example.test0.mapper.UserMapper.findById"))
    })
    public List<User> findAllTest0(User user);
}
